package com.joven.shelltest.test;

/**
 * 强密码校验规则
 * @Author wzj
 * @Date 2023-08-16 16:44
 **/
public class OtherTest5 {
    /**
     * 密码长度不少于8位且至少包含大写字母、小写字母、数字和特殊符号中的四种
     */
    public static final String password1 = "^(?![A-Za-z0-9]+$)(?![a-z0-9\\W]+$)(?![A-Za-z\\W]+$)(?![A-Z0-9\\W]+$)[a-zA-Z0-9\\W]{8,}$";
    //
    /**
     * 密码长度8-20位且至少包含大写字母、小写字母、数字或特殊符号中的任意三种
     */
    public static final String PASSWORD = "^(?![a-zA-Z]+$)(?![A-Z0-9]+$)(?![A-Z\\W_]+$)(?![a-z0-9]+$)(?![a-z\\W_]+$)(?![0-9\\W_]+$)[a-zA-Z0-9\\W_]{8,20}$";

    public static void main(String[] args) {
        //符合要求密码任意三种
        String password12 = "ABCDE01234!@#$%";
        //符合要求密码任意三种
        String password13 = "ABCDEabcde!@#$%";
        //符合要求密码任意三种
        String password14 = "ABCDEabcde01234";
        //符合要求密码任意三种
        String password15 = "abcde01234!@#$%";
        //符合要求密码任意三种 和 符合全部的四种
        String password16= "ABCabc012@#";


        System.out.println(password12.matches(PASSWORD)+ " 12");
        System.out.println(password13.matches(PASSWORD)+ " 13");
        System.out.println(password14.matches(PASSWORD)+ " 14");
        System.out.println(password15.matches(PASSWORD)+ " 15");
        System.out.println(password16.matches(PASSWORD)+ " 16");
    }

}
